package com.lagou.edu.remote;

import com.lagou.edu.message.entity.Message;
import com.lagou.edu.message.remote.MessageService;
import com.lagou.edu.server.PushServer;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 程  林
 * @date 2021-01-31 18:54
 * @description //
 * @since V1.0.0
 */
@RestController
public class MessageServiceImpl implements MessageService {

    @Override
    @PostMapping("/message/sendMsg")
    public Boolean sendMsg(Message message) {

        if (message == null) {
            return false;
        }
        try {
            PushServer.pushServer.push(message);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

        return true;
    }
}
